package com.k.kc.common.resp;

import java.time.Instant;

/**
 * @author kivil
 */
public class RespPageDto extends PageBase{
    private int code;
    private String msg;
    private Object data;

    public RespPageDto() {
    }

    public RespPageDto(int c, String m, Object d) {
        this.code = c;
        this.msg = m;
        this.data = d;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static RespPageDto getSuccess(Object data){
        return new RespPageDto(0,"SUCCESS",data);
    }

    public static RespPageDto getSuccess(){
        return getSuccess(null);
    }
    public static RespPageDto getError(){
        return new RespPageDto(-1,"ERROR",null);
    }

    public RespPageDto getSuccessForPager(Integer pageNo, Integer pageSize,Long totalRecordsCount,Integer limit,Integer offset, Object data){
        setPageNo(pageNo);
        setPageSize(pageSize);
        setLimit(limit);
        setOffset(offset);
        this.data = data;
        endPage(totalRecordsCount);
        return this;
    }
    /*public RespPageDto getSuccessForPager(Integer pageNo, Integer pageSize,Long totalRecordsCount){
        return getSuccessForPager(pageNo,pageSize,totalRecordsCount,null);
    }*/
    public RespPageDto getSuccessForPager(PageBase pageBase,Long totalRecordsCount,Object data){
        return getSuccessForPager(pageBase.getPageNo(),pageBase.getPageSize(),totalRecordsCount,pageBase.getLimit(),pageBase.getOffset(),data);
    }


}
